package cn.tannn.ops.backup.controller.dto;

import cn.tannn.jdevelops.result.bean.SerializableBean;
import cn.tannn.ops.backup.constant.DbType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 数据库备份
 *
 * @author tnnn
 * @version V1.0
 * @date 2024-9-10
 */
@Schema(description = "新增数据库备份")
@ToString
@Getter
@Setter
public class DbBackupAdd extends SerializableBean<DbBackupAdd> {

    /**
     * 数据库名
     */
    @Schema(description = "数据库名", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String dbName;


    /**
     * 数据库类型
     */
    @Schema(description = "数据库类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull
    private DbType dbType;


    /**
     * 数据库dump命令地址[mysql通过 which mysqldump 查询]
     */
    @Schema(description = "数据库dump命令地址[mysql通过 which mysqldump 查询]", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String dumpPath;


    /**
     * 数据库连接地址
     */
    @Schema(description = "数据库连接地址", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String host;


    /**
     * 连接名
     */
    @Schema(description = "连接名", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String name;


    /**
     * 数据库密码
     */
    @Schema(description = "数据库密码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String password;


    /**
     * 数据库端口
     */
    @Schema(description = "数据库端口", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull
    private Integer port;


    /**
     * 备份存储地址（远程服务器上的地址）
     */
    @Schema(description = "备份存储地址（远程服务器上的地址）", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String remoteBackupPath;


    /**
     * 数据库账户
     */
    @Schema(description = "数据库账户", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank
    private String user;


    /**
     * sshId[ssh_info表id]，根据这个进行备份的
     */
    @Schema(description = "sshId[ssh_info表id]，根据这个进行备份的")
    Long sshId;

    public @NotBlank String getDumpPath() {
        return dumpPath.trim();
    }

    public @NotBlank String getRemoteBackupPath() {
        return remoteBackupPath.trim();
    }
}
